/*
	@file: /log/source/formatter/DatetimeFormatter.cpp
	@author: Wolfhead
 */
#include "formatter/DatetimeFormatter.h"
#include <time.h>
#include <sys/time.h>
#include <vector>
#include <boost/date_time/posix_time/posix_time.hpp>


namespace logger
{

DatetimeFormatter::DatetimeFormatter(const std::string format)
	: m_format(format)
{

}

void DatetimeFormatter::do_format(
	LogDataPtr data_ptr,
	std::string & output)
{
	boost::posix_time::time_facet * tf_ptr = 
		new boost::posix_time::time_facet(m_format.c_str());

	std::ostringstream oss;
	oss.imbue(std::locale(std::locale::classic(), tf_ptr));
	oss << data_ptr->context.time;

	output.append(oss.str());
}


}//namespace logger
